feat(help): help topics, did-you-mean, humanized auth errors, command examples, completion help (PD-6074)#85
Merged
Conversation
leandroh
approved these changes
Jun 9, 2026
6213d7f to
bf3c283
Compare
Collaborator
Author
|
@greptile review |
…humanized auth errors, command examples, completion help (PD-6074)
bf3c283 to
8a2e10a
Compare
Collaborator
Author
|
@greptile review |
|
Promptless prepared a documentation update related to this change. Triggered by CLI PR #85 Documents CLI improvements: built-in help topics ( Review: Add changelog entry for CLI help and discoverability improvements |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Polishes the CLI surface for discoverability and automation. Adds long-form help topics, usage examples on every mutating command, "did you mean" suggestions on typos, humanized auth errors, and a deterministic
--no-inputpath so AI agents / CI scripts never block on interactive prompts.Help topics
New
lsh help <topic>pages grouped under a dedicated section oflsh --help:Each topic renders as a clean documentation page (no flag dump under it).
Did-you-mean
(
SuggestionsMinimumDistance = 2on rootCmd.)Humanized auth errors
utils.PrintErrorrewrites 401/403 from the API into actionable guidance:Detection (
hasStatusMarker) anchors on the bracketed[<status>]marker the go-openapi runtime emits, which shows up in two real shapes:[401] Unauthorized &{...}— generic response (what list endpoints return)[POST /servers][401] createServerUnauthorized ...— typed responseIt matches
[401]/[403]only at the start of the string or right after the]that closes the[<method> <path>]segment — so both shapes are caught while a bare[401]buried in an error payload is ignored, and loose words likeunauthorized(e.g."field 'role' has an unauthorized value") are never matched. Covered by a table-driven test ininternal/utils/response_utils_test.go.Examples on mutating commands
Every mutating command gained an
Example:field (Cobra renders these before flags, matching the clig.dev recommendation):api_keys,servers(create/update/reinstall/destroy/schedule-deletion),projects,ssh_keys,tags,virtual_networks(+assignments), pluslogin/auth status/auth logout/completion.Every example was verified against the command's actual flag set — this caught and fixed real
unknown flagbugs where examples used hyphens for flags that are underscore-named (--operating_system,--ssh_keys,--provisioning_type) and a stale--idonprojects destroy(real flag is--id_or_slug).SilenceUsage = trueon these commands keeps errors clean (no flag dump under "Error: ...").Cleaner flag descriptions
Removed hardcoded enum lists from generated flag descriptions (e.g.
--operating_system,--plan,--site,--raid,--environment,--provisioning_type). They went stale every time the API added a SKU/region/OS. Replaced with short prose +e.g. <one-example>using the correct dash-separated plan slugs (c2-small-x86).completionhelp rewriteThe generated cobra boilerplate (
yourprogram, a path that fails on Homebrew) was replaced with per-shell instructions that work for any install method — a portable~/.zsh/completions+compinitsetup for zsh and a~/.bashrcsource line for bash, with Homebrew shortcuts noted alongside.--no-inputfor agents and scriptsThe
--projectprompt now respects the existing--no-inputglobal flag. When set (or when stdin is not a TTY), commands that would otherwise open the interactive bubbletea picker exit with an actionable error:This matters because the bubbletea picker is not driveable by stdin strings — AI agents running inside a TTY (Claude Code, Aider, etc.) would otherwise hang on it.
lsh help automationdocuments the full non-interactive contract.Test plan
Notes
*_operation.gofiles are tagged// MANUAL — keep when regeneratingso a future swagger regeneration preserves them.{{.Long}}\n) — no third-party doc generator.Greptile Summary
This PR polishes the CLI's discoverability surface: four long-form
lsh help <topic>pages, "did you mean" suggestions on typos, humanized 401/403 errors with actionable guidance, a--no-inputfast-fail path for agents/CI, and usage examples on every mutating command. It also fixes the previously-flaggedtags updatebug whereAssignValueswas called on an anonymous struct literal, causing every update to silently send empty strings.help authentication|profiles|automation|output-formatstopics,SuggestionsMinimumDistance=2, andSilenceUsage=trueon mutating commands.HumanizeAPIErrordetects go-openapi's[401]/[403]markers at their two known anchor positions, avoiding false positives on validation messages.Confidence Score: 4/5
Safe to merge after correcting the invalid OS slug in the servers create example.
The servers create example uses ubuntu_22_04 which is not a recognized OS slug — the correct value is ubuntu_22_04_x64_lts. A user copying that example verbatim gets a validation error, which directly undermines the PR's goal of making examples accurate. All other changes look correct and well-tested.
cli/create_server_operation.go — the --operating_system value in the minimal deploy example needs to be corrected to ubuntu_22_04_x64_lts.
Comments Outside Diff (1)
cmd/tags/update.go, line 91-101 (link)AssignValuesresult is discarded — update always sends empty fieldsAssignValuesis called with a pointer to an anonymous struct literal initialised from the local variables (name,description,slug,color, all""). Reflection sets the flag values on that anonymous struct, but the local variables are never updated. When theUpdateTagTagsAttributesrequest is then built using&name,&description,&color, those pointers still reference the original empty strings.As a result, every
lsh tags updatecall sends""for all attributes, silently overwriting the tag's values rather than patching them. The fix is to use a named struct variable and read its fields when building the request.Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (3): Last reviewed commit: "feat(help): improve CLI help discoverabi..." | Re-trigger Greptile